package com.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.domain.DO.FlightInfo;
import com.domain.VO.FlightChoseRoleVo;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 大忽悠
 * @since 2022年11月08日
 */
public interface FlightInfoMapper extends BaseMapper<FlightInfo> {

    @SelectProvider(type = FlightInfoSqlProvider.class,method = "getValidFlightIdList")
    List<Integer> getValidFlightIdList(FlightChoseRoleVo flightChoseRoleVo);

    public static class FlightInfoSqlProvider{
        private final String TABLE_NAME="flight_info";

        public String getValidFlightIdList(FlightChoseRoleVo flightChoseRoleVo){
            return new SQL().SELECT("id").FROM(TABLE_NAME)
                    .WHERE("arrive_city=#{cityArrive}")
                    .WHERE("departure_city=#{cityLeave}")
                    .toString();
        }
    }
}
